package com.leyou.item.controller;

import com.leyou.item.pojo.SpecParam;
import com.leyou.item.service.SpecParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SpecParamController {
    @Autowired
    private SpecParamService specParamService;


    //@GetMapping("spec/params")
    public ResponseEntity<List<SpecParam>> querySpecParam(@RequestParam("cid") Long cid){
      List<SpecParam> specParams=  this.specParamService.querySpecParam(cid);
      if (specParams==null||specParams.size()==0){
          return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
      }
        return ResponseEntity.ok(specParams);
    }
}
